package bsts.view.user;

import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JButton;
import javax.swing.JPanel;

import bsts.application.BSTSApplication;

public class CustomerTabPanel extends JPanel {

	private static final long serialVersionUID = 1L;

	private BSTSApplication manager;

	private JPanel pnlMain;

	private JButton btnRegCust;
	// private JButton btnDeregCust;
	private JButton btnViewCustomers;
	private JButton btnLogComplaint;
	private JButton btnUpdComplaint;

	private ActionListener actlis_btnRegCust;
	private ActionListener actlis_btnViewCustomers;
	private ActionListener actlis_btnLogComplaint;
	private ActionListener actlist_btnUpdComplaint;

	public CustomerTabPanel(BSTSApplication manager) {
		this.manager = manager;

		pnlMain = new JPanel();
		pnlMain.setLayout(new GridLayout(9, 1, 0, 10));

		btnRegCust = new JButton("Register Customer");
		// btnDeregCust = new JButton( "Deregister Customer" );
		btnViewCustomers = new JButton("View Customers");
		btnLogComplaint = new JButton("Log Complaint");
		btnUpdComplaint = new JButton("View/Update Complaints");

		if (manager.isAdminRole())
			pnlMain.add(btnRegCust);
		// pnlMain.add( btnDeregCust );
		pnlMain.add(btnViewCustomers);
		pnlMain.add(btnLogComplaint);
		pnlMain.add(btnUpdComplaint);

		this.add(pnlMain);

		initActionListener();
	}

	private void initActionListener() {
		actlis_btnRegCust = new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				manager.getViewManager().showAddCustomerWindow(manager);
			}
		};

		actlis_btnViewCustomers = new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				manager.getViewManager().showViewCustomersWindow(manager);
			}
		};

		actlis_btnLogComplaint = new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				manager.getViewManager().showAddComplaintWindow();
			}
		};

		actlist_btnUpdComplaint = new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				manager.getViewManager().showViewComplaintsWindow();
			}
		};

		btnRegCust.addActionListener(actlis_btnRegCust);
		btnViewCustomers.addActionListener(actlis_btnViewCustomers);
		btnLogComplaint.addActionListener(actlis_btnLogComplaint);
		btnUpdComplaint.addActionListener(actlist_btnUpdComplaint);
	}

}